<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:body>
        <div class="change_pass">
            <f:view>
                <h:form>

                    <script type="text/javascript">
                                function confirmation() {
                                      var answer = confirm("Do you want Save?")
                                      if (answer){
                                          return true;
                                      }
                                      else{
                                          return false;
                                      }
                                }
                    </script>

                    <h3 style="color: #3F8AAC; margin: 10px 0 10px 25px;">
                        Enter the keyword :   <h:inputText style="font-family: Arial;font-size: 13px;"  value="#{vacancyManagedBean.name}"
                                                           valueChangeListener="#{vacancyManagedBean.findIDVancancy}">
                            <f:ajax  event="keyup" render="ajaxOutput"/>
                        </h:inputText> &nbsp;
                        <h:selectOneMenu   value="#{vacancyManagedBean.select}" style="font-family: Arial;font-size: 13px;" valueChangeListener="#{vacancyManagedBean.setQuery}">
                            <f:ajax event="change"/>
                            <f:selectItem itemLabel="---Select---" itemValue="0" ></f:selectItem>
                            <f:selectItem itemLabel="Vacancy ID" itemValue="1" ></f:selectItem>
                            <f:selectItem itemLabel="Vacancy Title" itemValue="2"></f:selectItem>
                        </h:selectOneMenu>
                    </h3>

                    <p:ajaxStatus>
                        <f:facet name="start">
                            <h:outputText value="#{vacancyManagedBean.mUpdateVa}" />
                        </f:facet>

                        <f:facet name="complete">
                            <h:outputText value="" />
                        </f:facet>
                    </p:ajaxStatus>  

                    <h:dataTable style="text-align: left;" columnClasses="bd_td1,bd_td,bd_td,bd_td,bd_td" cellpadding="3" cellspacing="1" border="0" styleClass="joblist" rowClasses="list_footer_cell" headerClass="list_header_cell"  id="ajaxOutput" value="#{vacancyManagedBean.findbyVacyTitleList}" var="item">

                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Vacancy Title"/>
                            </f:facet>
                            <p:inplace>
                                <p:inputText size="50" value="${item.vacantyTitle}" />
                            </p:inplace>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Positions"/>
                            </f:facet>
                            <p:inplace>
                                <p:inputText size="1" value="${item.numOfJob}" />
                            </p:inplace>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Start Date"/>
                            </f:facet>
                            <p:inplace>
                                <p:calendar value="#{item.startDate}">

                                    <f:convertDateTime pattern="MM/dd/yyyy" />

                                </p:calendar>
                            </p:inplace>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="DeadLine"/>
                            </f:facet>
                            <p:inplace>
                                <p:calendar value="#{item.closeDate}">

                                    <f:convertDateTime pattern="MM/dd/yyyy" />

                                </p:calendar>
                            </p:inplace>

                        </h:column>

                        <h:column >
                            <f:facet name="header">
                                <h:outputText value="Status"/>
                            </f:facet>

                            <h:panelGroup rendered="${item.vaStatus != 2}">
                                <h:selectOneMenu value="${item.vaStatus}" valueChangeListener="#{vacancyManagedBean.updateStatus1}">
                                    <f:selectItem itemLabel="Open" itemValue="1" ></f:selectItem>
                                    <f:selectItem itemLabel="Close" itemValue="2"></f:selectItem>
                                    <f:selectItem itemLabel="Suspended" itemValue="3"></f:selectItem>
                                    <f:ajax event="valueChange"/>
                                </h:selectOneMenu>
                            </h:panelGroup>



                            <h:panelGroup rendered="${item.vaStatus == 2}">
                                <h:selectOneMenu value="${item.vaStatus}" disabled="true">
                                    <f:selectItem itemLabel="Open" itemValue="1" ></f:selectItem>
                                    <f:selectItem itemLabel="Close" itemValue="2"></f:selectItem>
                                    <f:selectItem itemLabel="Suspended" itemValue="3"></f:selectItem>
                                </h:selectOneMenu>
                            </h:panelGroup>

                        </h:column>
                    </h:dataTable>

                    <table>
                        <tr>
                            <td style="text-align: left;">
                                <h:commandButton value="Save" onclick="return confirmation()" action="#{vacancyManagedBean.updateVacancy}"/>
                            </td>
                        </tr>
                    </table>
                </h:form>
            </f:view>
        </div>
    </h:body>
</html>

